//
//  LoginUserViewController.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/7/18.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "LoginUserViewController.h"
#import "RegisterNewPhoneCodeViewController.h"
#import "VerfityCodeViewController.h"
#import "ZAlertView.h"
#import "ZAlertViewManager.h"
#import <UMSocialCore/UMSocialCore.h>
#import <UShareUI/UMSocialUIUtility.h>
#import "HomepageViewController.h"
#import "UIButton+LZCategory.h"
@interface LoginUserViewController ()<UITextFieldDelegate>
@property(nonatomic,strong)UITextField *phoneTextFiled;
@property(nonatomic,strong)UITextField *secrectTextFiled;
@property(nonatomic,strong)UIView *view2;
@property(nonatomic,strong)UIView *view3;
@end

@implementation LoginUserViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createLoginVcUI];
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
    [self monitorNetwork];
}
-(void)createLoginVcUI{
    self.view.backgroundColor = [UIColor whiteColor];
    //****************头部背景*******************************
    UIImageView *titleImageView = [[UIImageView alloc] init];
    titleImageView.image = [UIImage imageNamed:@"背景"];
    [self.view addSubview:titleImageView];
    [titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(0);
        make.right.equalTo(self.view.mas_right);
        make.left.equalTo(self.view.mas_left);
        make.height.mas_equalTo(scaleTopAndBottom(172));
    }];
    UIView *view1 = [[UIView alloc] init];
    view1.backgroundColor = ZColorRGB(244.0, 190.0, 65.0);
    [self.view addSubview:view1];
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(15.0));
        make.top.equalTo(titleImageView.mas_bottom).offset(scaleTopAndBottom(20.0));
        make.width.mas_equalTo(scaleLeftAndRight(5));
        make.height.mas_equalTo(scaleTopAndBottom(20));
    }];
    UILabel *logLabel = [[UILabel alloc] init];
    logLabel.text = @"登录";
    [self.view addSubview:logLabel];
    [logLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view1.mas_right).offset(scaleLeftAndRight(5));
        make.right.equalTo(self.view.mas_right);
        make.height.mas_equalTo(scaleTopAndBottom(20));
        make.top.equalTo(titleImageView.mas_bottom).offset(scaleTopAndBottom(20.0));
    }];
    //******************第一个输入框布局*********************
    UIImageView *phoneImage = [[UIImageView alloc] init];
    phoneImage.image = [UIImage imageNamed:@"账号"];
    [self.view addSubview:phoneImage];
    [phoneImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(40));
        make.top.equalTo(logLabel.mas_bottom).offset(scaleTopAndBottom(35));
        make.width.mas_equalTo(scaleLeftAndRight(15));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UIImageView *clearImage = [[UIImageView alloc] init];
    clearImage.image = [UIImage imageNamed:@"SHANCHU"];
    clearImage.userInteractionEnabled = YES;
    UITapGestureRecognizer *clearTaop = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clearIntextContent)];
    [clearImage addGestureRecognizer:clearTaop];
    [self.view addSubview:clearImage];
    [clearImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-40));
        make.top.equalTo(logLabel.mas_bottom).offset(scaleTopAndBottom(35));
        make.width.mas_equalTo(scaleLeftAndRight(15));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    self.phoneTextFiled = [[UITextField alloc] init];
    self.phoneTextFiled.delegate = self;
    self.phoneTextFiled.placeholder = @"请输入手机号码";
    [self.view addSubview:self.phoneTextFiled];
    [self.phoneTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(phoneImage.mas_right).offset(scaleLeftAndRight(5));
        make.top.equalTo(logLabel.mas_bottom).offset(scaleTopAndBottom(28));
        make.height.mas_equalTo(scaleTopAndBottom(30));
        make.right.equalTo(clearImage.mas_left).offset(scaleLeftAndRight(-5));
    }];
    self.view2 = [[UIView alloc] init];
    [self.view addSubview:self.view2];
    self.view2.backgroundColor = [UIColor lightGrayColor];
    [self.view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-30));
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(30));
        make.top.equalTo(self.phoneTextFiled.mas_bottom).offset(scaleTopAndBottom(0));
        make.height.mas_equalTo(scaleTopAndBottom(1));
    }];
    ////******************第二个输入框布局*********************
    UIImageView *secrectImage = [[UIImageView alloc] init];
    secrectImage.image = [UIImage imageNamed:@"密码"];
    [self.view addSubview:secrectImage];
    [secrectImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(40));
        make.top.equalTo(self.view2.mas_bottom).offset(scaleTopAndBottom(35));
        make.width.mas_equalTo(scaleLeftAndRight(15));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UIButton *visualImageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [visualImageBtn setImage:[UIImage imageNamed:@"眼睛"] forState:UIControlStateNormal];
    [visualImageBtn addTarget:self action:@selector(visualInputWord:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:visualImageBtn];
    [visualImageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-40));
        make.top.equalTo(self.view2.mas_bottom).offset(scaleTopAndBottom(35));
        make.width.mas_equalTo(scaleLeftAndRight(15));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    self.secrectTextFiled = [[UITextField alloc] init];
    self.secrectTextFiled.delegate = self;
    self.secrectTextFiled.placeholder = @"请输入密码";
    self.secrectTextFiled.secureTextEntry = YES;
    [self.view addSubview:self.secrectTextFiled];
    [self.secrectTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(secrectImage.mas_right).offset(scaleLeftAndRight(5));
        make.top.equalTo(self.view2.mas_bottom).offset(scaleTopAndBottom(28));
        make.height.mas_equalTo(scaleTopAndBottom(30));
        make.right.equalTo(visualImageBtn.mas_left).offset(scaleLeftAndRight(-5));
    }];
    self.view3 = [[UIView alloc] init];
    [self.view addSubview:self.view3];
    self.view3.backgroundColor = [UIColor lightGrayColor];
    [self.view3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-30));
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(30));
        make.top.equalTo(self.secrectTextFiled.mas_bottom).offset(0);
        make.height.mas_equalTo(scaleTopAndBottom(1));
    }];
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [loginBtn setTitle:@"登  录" forState:UIControlStateNormal];
    loginBtn.titleLabel.font = [UIFont systemFontOfSize:20];
    [loginBtn addTarget:self action:@selector(userInformationLogin) forControlEvents:UIControlEventTouchUpInside];
    loginBtn.backgroundColor = ZColorRGB(244.0, 190.0, 65.0);
    loginBtn.layer.cornerRadius = scaleTopAndBottom(25);
    loginBtn.layer.masksToBounds = YES;
    [self.view addSubview:loginBtn];
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(scaleTopAndBottom(50));
        make.top.equalTo(self.view3.mas_bottom).offset(scaleTopAndBottom(50));
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(40));
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-40));
    }];
    ////*******************登录下面视图***************
    UIView *view4 = [[UIView alloc] init];
    view4.backgroundColor = [UIColor blackColor];
    [self.view addSubview:view4];
    [view4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(loginBtn.mas_bottom).offset(scaleTopAndBottom(40));
        make.height.mas_equalTo(scaleTopAndBottom(20));
        make.width.mas_equalTo(scaleLeftAndRight(1));
    }];
    UIButton *forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [forgetBtn setTitle:@"忘记密码?" forState:UIControlStateNormal];
    forgetBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [forgetBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [forgetBtn addTarget:self action:@selector(forgetSecrectAndFindSecrect) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:forgetBtn];
    [forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(loginBtn.mas_bottom).offset(scaleTopAndBottom(40));
        make.right.equalTo(view4.mas_left).offset(scaleLeftAndRight(-30));
        make.height.mas_equalTo(scaleTopAndBottom(20));
        make.width.mas_equalTo(scaleLeftAndRight(110));
    }];
    UIButton *registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [registerBtn setTitle:@"现在注册>" forState:UIControlStateNormal];
    [registerBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    forgetBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [registerBtn addTarget:self action:@selector(gotoRegisterPhone) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registerBtn];
    [registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(loginBtn.mas_bottom).offset(scaleTopAndBottom(40));
        make.left.equalTo(view4.mas_right).offset(scaleLeftAndRight(20));
        make.height.mas_equalTo(scaleTopAndBottom(20));
        make.width.mas_equalTo(scaleLeftAndRight(110));
    }];
    UILabel *thirdLabel = [[UILabel alloc] init];
    thirdLabel.text = @"使用第三方登录";
    thirdLabel.font = [UIFont systemFontOfSize:14];
    thirdLabel.textColor = [UIColor lightGrayColor];
    thirdLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:thirdLabel];
    [thirdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(view4.mas_bottom).offset(scaleTopAndBottom(30));
        make.height.mas_equalTo(scaleTopAndBottom(15));
    }];
    UIView *view5 = [[UIView alloc] init];
    view5.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:view5];
    [view5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(scaleTopAndBottom(1));
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(100));
        make.width.mas_equalTo(scaleLeftAndRight(25));
        make.top.equalTo(view4.mas_bottom).offset(scaleLeftAndRight(37.5));
    }];
    UIView *view6 = [[UIView alloc] init];
    view6.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:view6];
    [view6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(scaleTopAndBottom(1));
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-100));
        make.width.mas_equalTo(scaleLeftAndRight(25));
        make.top.equalTo(view4.mas_bottom).offset(scaleLeftAndRight(37.5));
    }];
    UIButton *QQBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [QQBtn setImage:[UIImage imageNamed:@"QQ"] forState:UIControlStateNormal];
    [QQBtn addTarget:self action:@selector(logQQInfomation) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:QQBtn];
    [QQBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(120));
        make.top.equalTo(view5.mas_bottom).offset(scaleTopAndBottom(30));
        make.height.mas_equalTo(scaleTopAndBottom(45));
        make.width.mas_equalTo(scaleLeftAndRight(45));
    }];
    UIButton *wechatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [wechatBtn setImage:[UIImage imageNamed:@"WEIIXN"] forState:UIControlStateNormal];
    [wechatBtn addTarget:self action:@selector(wechatLogIn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:wechatBtn];
    [wechatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-120));
        make.top.equalTo(view5.mas_bottom).offset(scaleTopAndBottom(30));
        make.height.mas_equalTo(scaleTopAndBottom(45));
        make.width.mas_equalTo(scaleLeftAndRight(45));
    }];
    UILabel *QQLabel = [[UILabel alloc] init];
    QQLabel.text = @"QQ";
    QQLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:QQLabel];
    [QQLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(120));
        make.top.equalTo(QQBtn.mas_bottom).offset(scaleTopAndBottom(10));
        make.height.mas_equalTo(scaleTopAndBottom(20));
        make.width.mas_equalTo(scaleLeftAndRight(45));
    }];
    UILabel *wechatLabel = [[UILabel alloc] init];
    wechatLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:wechatLabel];
    wechatLabel.text = @"微信";
    [wechatLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-120));
        make.top.equalTo(wechatBtn.mas_bottom).offset(scaleTopAndBottom(10));
        make.height.mas_equalTo(scaleTopAndBottom(20));
        make.width.mas_equalTo(scaleLeftAndRight(45));
    }];
}

#pragma mark -注册账号
-(void)gotoRegisterPhone{
    RegisterNewPhoneCodeViewController *registerVc = [[RegisterNewPhoneCodeViewController alloc] init];
    registerVc.headerTitile = @"手机号注册";
    registerVc.isRegister = YES;
    registerVc.type = @"0";
    [self presentViewController:registerVc animated:YES completion:nil];
}
#pragma mark -忘记密码
-(void)forgetSecrectAndFindSecrect{

//    VerfityCodeViewController *vc = [[VerfityCodeViewController alloc] init];
//    vc.backStr = @"找回密码";
//    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"phoneNumber"]) {
//        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//        manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//        NSString *url = ServerIp@"/customerApp/getSmsMail";
//        NSString *phoneNumber = [[NSUserDefaults standardUserDefaults] objectForKey:@"phoneNumber"];
//        NSDictionary *dict = @{@"phoneNumber":phoneNumber,@"type":@"1"};
//        [manager POST:url parameters:dict progress:^(NSProgress * _Nonnull uploadProgress) {
//            
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            
//        }];
//        [self presentViewController:vc animated:YES completion:^{
//            
//        }];
//
//    }
    RegisterNewPhoneCodeViewController *registerVc = [[RegisterNewPhoneCodeViewController alloc] init];
    registerVc.headerTitile = @"找回密码";
    registerVc.type = @"1";
    registerVc.isRegister = NO;
    [self presentViewController:registerVc animated:YES completion:nil];

}
#pragma mark -输入框的代理方法
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    self.view2.backgroundColor = [UIColor lightGrayColor];
    self.view3.backgroundColor = [UIColor lightGrayColor];
    return YES;
}
#pragma mark -清空输入内容
-(void)clearIntextContent{
    self.phoneTextFiled.text = @"";
}
#pragma mark -密码可见
-(void)visualInputWord:(UIButton *)btn{
    btn.selected = !btn.selected;
    if (btn.selected) {
        [btn setImage:[UIImage imageNamed:@"眼镜后"] forState:UIControlStateNormal];
        self.secrectTextFiled.secureTextEntry = NO;
    }else{
        [btn setImage:[UIImage imageNamed:@"眼睛"] forState:UIControlStateNormal];
        self.secrectTextFiled.secureTextEntry = YES;
    }
    
}
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    if ([textField isEqual:self.phoneTextFiled]) {
        self.view2.backgroundColor = [UIColor yellowColor];
        self.view3.backgroundColor = [UIColor lightGrayColor];
    }else{
        self.view2.backgroundColor = [UIColor lightGrayColor];
        self.view3.backgroundColor = [UIColor yellowColor];
    }
    return YES;
}
#pragma mark -网络检测
-(void)monitorNetwork{

    AFNetworkReachabilityManager *netMonitor = [AFNetworkReachabilityManager sharedManager];
    [netMonitor startMonitoring];
    [netMonitor
     setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
         switch (status) {
             case AFNetworkReachabilityStatusUnknown:
                 NSLog(@"未识别的网络");
                 break;
                 
             case AFNetworkReachabilityStatusNotReachable:{
                    [[ZAlertViewManager shareManager] showWithType:1];
                 NSLog(@"无网络连接");
             }
                 break;
                 
             case AFNetworkReachabilityStatusReachableViaWWAN:
             {
                   [[ZAlertViewManager shareManager] dismissWithTime:0];
                 NSLog(@"2G,3G,4G...的网络");
             }
                 
                 break;
                 
             case AFNetworkReachabilityStatusReachableViaWiFi:
             {
                    [[ZAlertViewManager shareManager] dismissWithTime:0];
                   NSLog(@"wifi的网络");
             }
                 break;
             default:
                 break;
         }
     }];
}
#pragma mark -用户信息登录
-(void)userInformationLogin{
    [self monitorNetwork];
//    HomepageViewController *homePage = [[HomepageViewController alloc] init];
//    [self presentViewController:homePage animated:YES completion:^{
//        
//    }];
    if ([self.phoneTextFiled.text  isEqual: @""] || [self.secrectTextFiled.text isEqual: @""]) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"用户名或者账号不能为空" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }else{
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        manager.responseSerializer = [AFHTTPResponseSerializer serializer];
        NSString *url = ServerIp@"/customerApp/customerLogin";
        NSDictionary *param = @{@"phoneNumber":self.phoneTextFiled.text,@"passWord":self.secrectTextFiled.text,@"type":@"0"};
        [manager POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
            
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
            if ([dict[@"result"] integerValue] == 0) {
                NSDictionary *customerDic = dict[@"customer"];
                [[NSUserDefaults standardUserDefaults] setObject:customerDic[@"sessionId"] forKey:@"sessionId"];
                //********************测试登录**************
                HomepageViewController *homePage = [[HomepageViewController alloc] init];
                [self presentViewController:homePage animated:YES completion:^{
                    
                }];
                NSLog(@"%@",dict);
            }else{
                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:dict[@"msg"] message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [alertView show];
            }
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            
        }];

    }


}
#pragma mark -QQ登录
-(void)logQQInfomation{
    [self getAuthWithUserInfoFromQQ];
}

- (void)getAuthWithUserInfoFromQQ
{
    [[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_QQ currentViewController:nil completion:^(id result, NSError *error) {
        if (error) {
            NSLog(@"无论什么原因，它不同意");
        } else {
            UMSocialUserInfoResponse *resp = result;
            
            // 授权信息
            NSLog(@"QQ uid: %@", resp.uid);
            NSLog(@"QQ openid: %@", resp.openid);
            NSLog(@"QQ unionid: %@", resp.unionId);
            NSLog(@"QQ accessToken: %@", resp.accessToken);
            NSLog(@"QQ expiration: %@", resp.expiration);
            // 用户信息
            NSLog(@"QQ name: %@", resp.name);
            NSLog(@"QQ iconurl: %@", resp.iconurl);
            NSLog(@"QQ gender: %@", resp.unionGender);
            // 第三方平台SDK源数据
            NSLog(@"QQ originalResponse: %@", resp.originalResponse);
            AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
            manager.responseSerializer = [AFHTTPResponseSerializer serializer];
            NSString *url = ServerIp@"/customerApp/customerLogin";
            NSDictionary *param = @{@"qqUnionid":resp.unionId,@"type":@"2"};
            [manager POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                NSLog(@"%@",dict[@"msg"]);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                NSLog(@"失败了为什么%@",error);
            }];

        }
    }];
}

#pragma mark -微信登录
-(void)wechatLogIn{
    [self getAuthWithUserInfoFromWechat];
}
- (void)getAuthWithUserInfoFromWechat
{
    [[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_WechatSession currentViewController:nil completion:^(id result, NSError *error) {
        if (error) {
            NSLog(@"无论什么原因，它不同意");
        } else {
            UMSocialUserInfoResponse *resp = result;
            // 授权信息
            NSLog(@"Wechat uid: %@", resp.uid);
            NSLog(@"Wechat openid: %@", resp.openid);
            NSLog(@"Wechat unionid: %@", resp.unionId);
            NSLog(@"Wechat accessToken: %@", resp.accessToken);
            NSLog(@"Wechat refreshToken: %@", resp.refreshToken);
            NSLog(@"Wechat expiration: %@", resp.expiration);
            // 用户信息
            NSLog(@"Wechat name: %@", resp.name);
            NSLog(@"Wechat iconurl: %@", resp.iconurl);
            NSLog(@"Wechat gender: %@", resp.unionGender);
            // 第三方平台SDK源数据
            NSLog(@"Wechat originalResponse: %@", resp.originalResponse);
        }
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
